<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml" 
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:pe="http://primefaces.org/ui/extensions"
                xmlns:hr="http://java.sun.com/jsf/composite/autocomplete">

    <ui:define name="content">

        <h:form>

            <h:outputScript library="js" name="excellentexport.js" ></h:outputScript>

            <p:selectOneMenu id="advanced" 
                             value="#{salaryCycleController.current}" 
                             converter="salaryCycleConverter" 
                             effect="fade" var="t" 
                             filter="true" 
                             filterMatchMode="startsWith">

                <f:selectItems value="#{salaryCycleController.salaryCycles}" 
                               var="theme" 
                               itemLabel="#{theme.name}" 
                               itemValue="#{theme}" ></f:selectItems>

                <p:column style="width:10%" headerText="Name">
                    <h:outputText value="#{t.name}" />
                </p:column>

                <p:column headerText="Year">
                    <h:outputText value="#{t.salaryYear}" />
                </p:column>
                <p:column headerText="Month">
                    <h:outputText value="#{t.salaryMonth}" />
                </p:column>
            </p:selectOneMenu>

            
            <p:commandButton value="Print" ajax="false" action="#"  >
                <p:printer target="print" ></p:printer>
            </p:commandButton>
            <p:commandButton value="Process" ajax="false" action="#{salaryCycleController.fillStaffAndSalaryComponents()}" ></p:commandButton>

<!--            <p:commandLink style="padding: .3em 1em;" 
                           styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-button-text ui-c" ajax="false" value="Download as Excel" 
                           download="#{salaryCycleController.current}.xls" 
                           onclick="return ExcellentExport.excel(this, 'tbl', 'Sheet1');" ></p:commandLink>
            -->
            
             <a download="#{salaryCycleController.current}.xls" href="#" 
                onclick="return ExcellentExport.excel(this, 'tbl', 'Sheet1');"
                           style="padding: .3em 1em;  background: #D7D0C0; " 
                           styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-button-text ui-c noPrintButton" >Download as Excel</a>

            
            <p:panel id="print">
                <table id="tbl" border="1">
                    <thead>
                        <tr>
                            <th>EMP Code</th>
                            <th>Staff Name</th>
                            <ui:repeat value="#{salaryCycleController.headersAdd}" var="h">
                                <th>#{h}</th>
                            </ui:repeat>
                            <th>Gross Salary</th>
                            <ui:repeat value="#{salaryCycleController.headersSub}" var="hh">
                                <th>#{hh}</th>
                            </ui:repeat>
                            <th>EPF</th>
                            <th>ETF</th>
                            <th>Net Salary</th>
                        </tr>
                    </thead>
                    <tbody>                   
                        <ui:repeat value="#{salaryCycleController.staffAnsAndSalarySalaryComponents}" var="scc">
                            <tr>
                                <td><h:outputLabel value="#{scc.staff.code}" /></td>
                                <td><h:outputLabel value="#{scc.staff.person.nameWithTitle}" /></td>
                                <ui:repeat value="#{scc.staffSalaryComponantsAddition}"  var="col">
                                    <td><h:outputText value="#{col.componantValue}" >
                                            <f:convertNumber pattern="0.00" />
                                        </h:outputText>
                                    </td>
                                </ui:repeat>
                                <td><h:outputLabel value="#{scc.valueAdding}" >
                                        <f:convertNumber pattern="0.00" />
                                    </h:outputLabel>
                                </td>
                                <ui:repeat value="#{scc.staffSalaryComponantsSubstraction}"  var="col2">
                                    <td><h:outputText value="#{col2.componantValue}" >
                                            <f:convertNumber pattern="0.00" />
                                        </h:outputText>
                                    </td>
                                </ui:repeat>
                                <td><h:outputLabel value="#{scc.epf}" >
                                        <f:convertNumber pattern="0.00" />
                                    </h:outputLabel>
                                </td>
                                <td><h:outputLabel value="#{scc.etf}" >
                                        <f:convertNumber pattern="0.00" />
                                    </h:outputLabel>
                                </td>
                                <td><h:outputLabel value="#{scc.valueAdding+(scc.valueSubstarction+scc.epf+scc.etf)}" >
                                        <f:convertNumber pattern="0.00" />
                                    </h:outputLabel>
                                </td>
                            </tr>
                            
                            
<!--                            <tr>
                                <td></td>
                                <td></td>
                                <ui:repeat value="#{scc.staffSalaryComponantsAddition}"  var="col">
                                    <td><h:outputText value="#{col.componantValue}" >
                                            <f:convertNumber pattern="0.00" />
                                        </h:outputText>
                                    </td>
                                </ui:repeat>
                                <ui:repeat value="#{salaryCycleController.footerAdd}" var="f">
                                <td>#{f}</td>
                            </ui:repeat>
                                <td><h:outputLabel value="#{scc.valueAdding}" >
                                        <f:convertNumber pattern="0.00" />
                                    </h:outputLabel>
                                </td>
                                <ui:repeat value="#{scc.staffSalaryComponantsSubstraction}"  var="col2">
                                    <td><h:outputText value="#{col2.componantValue}" >
                                            <f:convertNumber pattern="0.00" />
                                        </h:outputText>
                                    </td>
                                </ui:repeat>
                                <td><h:outputLabel value="#{scc.epf}" >
                                        <f:convertNumber pattern="0.00" />
                                    </h:outputLabel>
                                </td>
                                <td><h:outputLabel value="#{scc.etf}" >
                                        <f:convertNumber pattern="0.00" />
                                    </h:outputLabel>
                                </td>
                                <td><h:outputLabel value="#{scc.valueAdding+(scc.valueSubstarction+scc.epf+scc.etf)}" >
                                        <f:convertNumber pattern="0.00" />
                                    </h:outputLabel>
                                </td>
                            </tr>-->
                            
                        </ui:repeat>
                    </tbody>
                </table>

            </p:panel>


        </h:form> 



    </ui:define>

</ui:composition>
